<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="./js/jquery-3.4.1.js"></script>
<script>

	$(document).ready(() => {

		$("[name='uname']").on("blur", (evnet)=>{

			let uname = $(evnet.target).val()

			/* $.ajax({
				type: "post",
				url: "./test.ajax",
				data: {uname}, // {uname:uname}
				dataType: "json",
				success(data) {
					console.info(data)
					$(msg).html(`用户名：${data.username}, 年龄是： ${data.age}`)
				},
				error(e) {
					console.info(e)
				}
			}) */

			$.post("./test.ajax", {uname}, (data)=>{
				console.info(data)
				$(msg).html(`用户名：${data.username}, 年龄是： ${data.age}`)
			}, "json")
		})


	})



</script>
</head>
<body>
	<h1>hello world</h1>
	<input name="uname"  />
	<div id="msg" style="color:blue"></div>

	<hr />
</body>
</html>